package com.theten52.demo.demo1;

/**
 * 增补字符的使用
 *
 * @author wangjin
 * @date 2020/6/9
 */
public class IdDemo2 {
    public static void main(String[] args) {
        int codePoint = 0x28e16;
        //将代码点转换成字符数组，取得代理对编码值。
        char[] c = Character.toChars(codePoint);
        String s = String.valueOf(c);
        System.out.println("增补字符为：" + s);
        System.out.println("String长度：" + s.length());
        System.out.println("String代码点数：" + s.codePointCount(0, s.length()));
        System.out.println("高代理字符编码值：U+" + Integer.toHexString(c[0]));
        System.out.println("低代理字符编码值：U+" + Integer.toHexString(c[1]));
        //调用Character方法取得代理对编码值。
        String high = Integer.toHexString(Character.highSurrogate(codePoint));
        String low = Integer.toHexString(Character.lowSurrogate(codePoint));
        System.out.println("高代理字符编码值：U+" + high);
        System.out.println("低代理字符编码值：U+" + low);
        //通过代理对取得代码点。
        int codePoint2 = Character.toCodePoint(c[0], c[1]);
        System.out.println("代码点:" + Integer.toHexString(codePoint2));

        System.out.println("㊣");
        s = "㊣";
        System.out.println("增补字符为：" + s);
        System.out.println("String长度：" + s.length());
        System.out.println("String代码点数：" + s.codePointCount(0, s.length()));
        System.out.println("高代理字符编码值：U+" + Integer.toHexString(c[0]));
        System.out.println("低代理字符编码值：U+" + Integer.toHexString(c[1]));
        //调用Character方法取得代理对编码值。
        high = Integer.toHexString(Character.highSurrogate(codePoint));
        low = Integer.toHexString(Character.lowSurrogate(codePoint));
        System.out.println("高代理字符编码值：U+" + high);
        System.out.println("低代理字符编码值：U+" + low);
        //通过代理对取得代码点。
        codePoint2 = Character.toCodePoint(c[0], c[1]);
        System.out.println("代码点:" + Integer.toHexString(codePoint2));
    }
}
